#pragma once
#include <string>
#include <memory>
namespace rtbus {
class CANItf
{
public:
    virtual ~CANItf() {}
    struct FrameData
    {
        uint32_t id;
        uint8_t data[8];
        uint8_t dlc;
    };
    virtual int send(FrameData* frame, size_t cnt) = 0;
    virtual int recv(FrameData* data, size_t cnt) = 0;

public:
    struct Config
    {
        std::string adapter_name;
        uint8_t dev_id;
        uint8_t can_id;
    };
    enum class CANType
    {
        CONTROLCAN,
        SOCKETCAN
    };
    virtual int load_cfg(Config& cfg) = 0;
    virtual int active() = 0;
    virtual int deactive() = 0;
    virtual CANType type() = 0;
};

std::shared_ptr<CANItf> create_can(CANItf::CANType type);
}  // namespace rtbus
